package org.mengyun.tcctransaction.sample.action;

import org.mengyun.tcctransaction.sample.domain.dto.OrderDto;
import org.mengyun.tcctransaction.sample.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by changming.xie on 4/1/16.
 */
@RestController
@RequestMapping("")
public class CreditController {

	@Autowired
	OrderService orderService;

	@RequestMapping(value = "/order/{userId}/{productId}/{num}", method = RequestMethod.GET)
	public String order(@PathVariable long userId, @PathVariable long productId, @PathVariable int num) {
		OrderDto od = new OrderDto();
		od.setUserId(userId);
		od.setProductId(productId);
		od.setNum(num);
		orderService.tryCreateOrder(od);
		return "ok";
	}

}
